import 'package:flutter/material.dart';
import 'package:flutter_demo/ui/pages/status/data/counter_notifier.dart';
import 'package:flutter_demo/ui/pages/status/data/share_data.dart';
import 'package:flutter_demo/ui/pages/status/data/share_data_proxy.dart';
import 'package:flutter_demo/ui/pages/status/data/share_data_proxy_notifier.dart';
import 'package:provider/provider.dart';

class B2PageWidget extends StatefulWidget {
  const B2PageWidget({super.key});

  @override
  State<B2PageWidget> createState() => _B2PageWidgetState();
}

class _B2PageWidgetState extends State<B2PageWidget> {
  @override
  Widget build(BuildContext context) {
    print("重新构建 B2PageWidget");
    ShareData shareData = Provider.of<ShareData>(context);
    ShareDataProxy shareDataProxy = Provider.of<ShareDataProxy>(context);
    ShareDataProxyNotifier shareDataProxyNotitier =
        Provider.of<ShareDataProxyNotifier>(context);

    return Column(
      children: [
        Text("${shareData.nickname}"),
        Text("${shareDataProxy.tab}"),
        Text("${shareDataProxyNotitier.tab}"),
        SizedBox(
          height: 20,
        ),
        ElevatedButton(
          onPressed: () {
            shareDataProxy.changeName("hello proxy");
          },
          child: Text("B页面: shareDataProxy更改nickname的值"),
        ),
        ElevatedButton(
          onPressed: () {
            shareDataProxyNotitier.changeName("hello proxy notitier");
          },
          child: Text("B页面: shareDataProxyNotitier更改nickname的值"),
        ),
        SizedBox(
          height: 20,
        ),
        // ElevatedButton(
        //   onPressed: () {
        //     Navigator.of(context).pop();
        //   },
        //   child: Text("B页面:使用路由情况返回A"),
        // ),
      ],
    );
  }
}
